package Test;

import junit.framework.Assert;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import ControlLayer.RoomTypeCtr;
import ModelLayer.RoomType;

public class RoomTypeCtrTest {
	private RoomTypeCtr rtCtr;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		rtCtr = new RoomTypeCtr();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testInsertAndGetRoomType() {
		int rtId = rtCtr.insertRoomType("FamilyRoom", 200, 4);
		RoomType rt = rtCtr.getRoomType(rtId);
		Assert.assertEquals(rtId, rt.getId());
		Assert.assertEquals("FamilyRoom", rt.getName().toString());
		Assert.assertEquals(200.0, rt.getPricePerNight());
		Assert.assertEquals(4, rt.getSize());
		rtCtr.deleteRoomType(rtId);
	}

	@Test
	public void testUpdateRoomType() {
		int rtId = rtCtr.insertRoomType("FamilyRoom", 200, 4);
		rtCtr.updateRoomType(rtId, "DoubleRoom", 100, 2);
		RoomType rt = rtCtr.getRoomType(rtId);
		Assert.assertEquals(rtId, rt.getId());
		Assert.assertEquals("DoubleRoom", rt.getName().toString());
		Assert.assertEquals(100.0, rt.getPricePerNight());
		Assert.assertEquals(2, rt.getSize());
		rtCtr.deleteRoomType(rtId);
	}

	@Test
	public void testDeleteRoomType() {
		int rtId = rtCtr.insertRoomType("FamilyRoom", 200, 4);
		Assert.assertEquals(1, rtCtr.deleteRoomType(rtId));
	}

}
